import './assets/main.scss'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import mitt, { type Emitter } from 'mitt'
import App from './App.vue'
import router from './router'
import type { BusEvents } from './types/bus'
import 'element-plus/dist/index.css'

const app = createApp(App)

app.use(createPinia().use(piniaPluginPersistedstate))
app.use(router)

// 全局指令
app.directive('focus', {
  mounted(el: HTMLElement) {
    el.focus()
  },
})
const Bus: Emitter<BusEvents> = mitt<BusEvents>()
app.config.globalProperties.$appName = 'Vue3 TS Vite Hello'
app.config.globalProperties.$bus = Bus

app.mount('#app')

declare module 'vue' {
  export interface ComponentCustomProperties {
    $appName: string
    $bus: typeof Bus
  }
}
